package com.wsoft.mq.test.sample.direct;

import com.rabbitmq.client.Channel;
import com.wsoft.mq.constant.ImConstant;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

/**
 * @Author z001
 * @Date 2025/1/7 15:40
 */
@Component
public class DirectReceiveSample2 {

    @RabbitListener(queues = ImConstant.IM_FORM_USER_SINGLE_QUEUE,ackMode="MANUAL")
    public void listener(Message message, Object content,
                         Channel channel,
                         @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) throws Exception {
        channel.basicAck(deliveryTag, false);
        System.out.println("direct-收到信息2,content:" + content);
    }

}
